﻿<UserControl x:Class="WpfImageDuplicates.FilterCollectionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:y="clr-namespace:WpfImageDuplicates"
             xmlns:dragdrop="clr-namespace:DragDropLibrary;assembly=DragAndDrop"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="clr-namespace:ImageAppViewModels"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">    
    <UserControl.CommandBindings>
        <CommandBinding Command="{x:Static y:GeneralCommands.RemoveFilterCommand}" Executed="RemoveFilter"/>
        <CommandBinding Command="{x:Static y:GeneralCommands.RemoveSelectedFiltersCommand}" Executed="RemoveSelectedFilters"/>
    </UserControl.CommandBindings>
    <Grid x:Name="gridMain">
        <Grid.RowDefinitions>
            <RowDefinition Height="18"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="20"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*"/>
            <ColumnDefinition Width="0.5*"/>
        </Grid.ColumnDefinitions>
        <TextBlock FontSize="10" FontWeight="Bold" Text="Current Filters:" HorizontalAlignment="Left" VerticalAlignment="Center" />
        <TextBlock Grid.Column="1" FontSize="10" FontWeight="Bold" Text="Available Filters:" HorizontalAlignment="Left" VerticalAlignment="Center" />        
        <ListBox Grid.Row="1" Name="lstItems" ItemsSource="{Binding}"  SelectionMode="Extended" 
                 dragdrop:DragAndDrop.DropMethodName="DropFilter"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible">            
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Width="Auto" HorizontalAlignment="Stretch"  Height="Auto" BorderBrush="Black" BorderThickness="1,1,1,1" Padding="0,0,0,0">
                        <!--Padding="1,1,1,1"-->
                        <y:FilterView x:Name="filterView" FilterViewModel="{Binding}" Width="Auto" Height="22" HorizontalAlignment="Stretch" Margin="0,0,0,0"
                                      FilterCollectionViewModel="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext}"
                                      PropertyChanged="filterView_PropertyChanged"                                                                           
                                      Drop="filterView_Drop" 
                                      />                        
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>        
        <y:ShowAvailableFilters Grid.Row="1" x:Name="showAvailable" Grid.Column="1" WantAddFilter="showAvailable_WantAdd"/>
        <Grid Grid.Column="1" Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.33*"/>
                <ColumnDefinition Width="0.33*"/>
                <ColumnDefinition Width="0.34*"/>
            </Grid.ColumnDefinitions>
            <Button FontSize="10" x:Name="btnAddFilter" Click="btnAddFilter_Click" Content="Add Selected Filter(s)"></Button>
            <ToggleButton FontSize="10" Grid.Column="1" IsChecked="{Binding Mode=TwoWay, Path=WantFilterThumbs}" Content="Apply Filters to Thumbnails"/>
            <ToggleButton FontSize="10" Grid.Column="2" IsChecked="{Binding Mode=TwoWay, Path=HighQualityThumbs}" Content="High Quality Thumbnails"/>
        </Grid>
        
        <Grid Grid.Column="0" Grid.Row="2" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.33*"/>
                <ColumnDefinition Width="0.33*"/>
                <ColumnDefinition Width="0.34*"/>
            </Grid.ColumnDefinitions>
            <ToggleButton FontSize="10" Grid.Column="0" x:Name="btnToggle" IsChecked="{Binding Mode=TwoWay, Path=Active}">
                <ToggleButton.Content>
                    <TextBlock FontSize="10" Text="{Binding ActiveOrDisabled}"/>
                </ToggleButton.Content>
            </ToggleButton>
            <Button FontSize="10" Grid.Column="1" x:Name="btnClearFilters" Click="btnClearFilters_Click" Content="Clear All Filters in Collection"></Button>
            <Button FontSize="10" Grid.Column="2" x:Name="btnRemoveSelected" 
                    Command="{x:Static y:GeneralCommands.RemoveSelectedFiltersCommand}" 
                    CommandParameter="{Binding}"
                    Content="Remove Selected Filters from Collection"></Button>
        </Grid>        
    </Grid>
</UserControl>
